<?php

class UsuarioDAO extends DaoModel {

    public function __construct() {
        parent::__construct("Usuario");
    }

    
    public function obterUsuarioPorCPFeSenha($cpf,$password){
        
        $sql = "SELECT u.* FROM seguranca.usuario u
                INNER JOIN pessoal.colaborador c ON u.ide_colaborador = c.ide_colaborador
                WHERE u.des_senha = '{$password}' AND c.num_cpf = '{$cpf}' AND u.des_status = 'A'";

        $result = $this->select($sql);
        
        if($result){
            $exception = array(); 
            $exception['select']['perfil'] = "ide_perfil IN (select ide_perfil from seguranca.perfil where ide_sistema = " . OID_SIS . ")";
            $exception['load'] = array(
                'senha' => false,
                'perfil' => array(
                    'usuarios' => false
                    )
                );
            $objUsuario = $this->loadObject($result, false, $exception);
            return $objUsuario;
        }else{
            return false;
        }

    }    
    
}

?>
